import React from 'react'

class Handler extends React.Component {
  constructor() {
    super();
    this.state = {
      count: 100
    }
    this.handleClick = this.handleClick.bind(this)
  }
  
  handleClick() {
    console.log(this) // this指向组件实例
    this.setState({
      count: this.state.count - 1
    })
  }
  render() {
    return (
      <div>
        <div>我是类组件</div>
        <p>{this.state.count}</p>
        <button onClick={this.handleClick}>点击改变状态</button>
      </div>
    )
  }
}

export default Handler